﻿@using BonjourQuotation.UI.Models.PartialModel
@model QuotationBusGridViewModel
@{
    //bool functBtn = true;
    //functBtn = !User.IsInRole("accountant");
}
<div id="VendorContractBus" style="display:none;">
</div>
@using (Ajax.BeginForm("UpdateQuotationBus", "Quotation", new AjaxOptions() { HttpMethod = "Post", UpdateTargetId = "tabBus", InsertionMode = InsertionMode.Replace, OnComplete = "QuotaBusTabAjaxComplete()" }, new { enctype = "multipart/form-data", id = "QuotaBusGridForm" }))
{
    @Html.HiddenFor(model => model.QuotaBusErrorCode)
    @Html.HiddenFor(model => model.QuotaBusErrorMessage)
   <table class="table table-bordered table-hover">
    <th>#</th>
    <th>Day</th>
    <th>Date</th>
    <th>Service</th>
    <th>Description</th>
    <th>M</th>
    <th>Rate</th>
    @*<th>#</th>*@
    <th># Days</th>
    <th>Cost</th>
    <th>Curr</th>
    @if (Model.QuotaBusRemoveBtnView && !(Model.QuotaBusConfirmed))
    {
        <th>del</th>
    }
    <tbody>
        @if(Model.Rows.Count>0)
        { 
            @Html.HiddenFor(model=>model.Rows[0].QuotaID)
        }
        @for (int ind = 0; ind < Model.Rows.Count; ind++)
{
    Model.SelServiceID = Model.Rows[ind].SelectedServiceID;
    <tr class="@(@Model.Rows[ind].CurrencyBus == "CA" ? "trCurrencyCad" : "") @(@ind % 2 == 0 ? "trRowBackground1" : "")">
        <td class="tdBorderBlack">@Html.LabelForModel(Model.Rows[ind].LineNo)</td>@Html.HiddenFor(model => model.Rows[ind].LineNo)
        <td class="tdBorderBlack">
            @Html.TextBoxFor(model => Model.Rows[ind].Day, new { @class = "QuotaOnlyDigits QuotaDay QuotaTextBx table_inputs_50 table_inputs_WithoutBox BusDetTab DayCls" })
        </td>
        @if (Model.Rows[ind].LineDate.Contains("Fri") || Model.Rows[ind].LineDate.Contains("Sat"))
        {
            <td class="tdBorderBlack">
                @Html.LabelForModel(Model.Rows[ind].LineDate, new { @class = "table_inputs_Date QuotaDatesFriSat" })
                @Html.HiddenFor(model => model.Rows[ind].LineDate)
            </td>
        }
        else
        {
            <td class="tdBorderBlack">
                @Html.LabelForModel(Model.Rows[ind].LineDate, new { @class = "table_inputs_Date" })
                @Html.HiddenFor(model => model.Rows[ind].LineDate)
            </td>
        }
        <td class="tdBorderBlack">
            @Html.DropDownListFor(model => model.SelServiceID, new SelectList(Model.Service, "Value", "Text"), new { @class = "table_inputs_160 BusServiceDrop BusDetTab", @style = "height:23px;" })
            @Html.DropDownListFor(model => Model.Rows[ind].SelectedServiceID, new SelectList(Model.Service, "Value", "Text"), new { @class = "RoomGridDropHide" })
        </td>
        @if (Model.Rows[ind].BusMFlag == false)
        {
            <td class="tdBorderBlack">
                @Html.TextBoxFor(model => Model.Rows[ind].DescriptionBus, new { @class = "table_inputs_550 table_inputs_WithoutBox BusDetTab QuotaTxtComplete" })
                @Html.HiddenFor(model => Model.Rows[ind].VendorID, new { @class = "BusID" })
            </td>
        }
        else
        {
            <td class="tdBorderBlack">
                @Html.TextBoxFor(model => Model.Rows[ind].DescriptionBus, new { @class = "table_inputs_550 table_inputs_WithoutBox BusDetTab" })
                @Html.HiddenFor(model => Model.Rows[ind].VendorID, new { @class = "BusID" })
            </td>
        }
        <td class="tdBorderBlack">
            @Html.CheckBoxFor(model => Model.Rows[ind].BusMFlag, new { @class = "QuotaRemTxtComplete BusDetTab BusMFlag", @tabindex = "-1" })
        </td>
        <td class="tdBorderBlack">
            @Html.TextBoxFor(model => Model.Rows[ind].Rate, new { @class = "QuotaOnlyDecimalDigits QuotaTextBx table_inputs_Decimal BusRate table_inputs_WithoutBox BusDetTab QuotaMoneyTxb" })
        </td>
        @*<td>
                @Html.TextBoxFor(model => Model.Rows[ind].Qty, new { @class = "table_inputs BusDetTab" })
            </td>*@
        <td class="tdBorderBlack">
            @Html.TextBoxFor(model => Model.Rows[ind].DayQty, new { @class = "QuotaOnlyDigits table_inputs_50 table_inputs_WithoutBox BusDetTab DayCls QuotaTextBx" })
        </td>
        <td class="tdBorderBlack">
            @Html.LabelForModel(Model.Rows[ind].Cost, new { @class = "table_inputs_60 Label_QuotaGrd" })
        </td>
        <td class="tdBorderBlack">
            @if (Model.Rows[ind].CurrencyBus == "CA")
            { 
                @Html.TextBoxFor(model => Model.Rows[ind].CurrencyBus, new { @class = "QuotaTextBx CurrencyBus table_inputs_50 table_inputs_WithoutBox BusDetTab QuotationCurrCAD" })
            }
            else
            {
                @Html.TextBoxFor(model => Model.Rows[ind].CurrencyBus, new { @class = "QuotaTextBx CurrencyBus table_inputs_50 table_inputs_WithoutBox BusDetTab" })
            }
        </td>
        @if (Model.QuotaBusRemoveBtnView && !(Model.QuotaBusConfirmed))
        { 
            <td><button class="btndel" style="padding:0px;" type="button" onclick="RemoveBus('@Model.Rows[ind].BusID','@Model.Rows[ind].LineNo')"></button></td>
        }
    </tr>
}
    </tbody>
</table>
    if (Model.QuotaBusInsertBtnView && !(Model.QuotaBusConfirmed))
    {
        <input type="number" class="QuotaTabInsertTxb" id="BusInsertLine" min="1" value="1" />
        <button class="btn14" type="button" onclick="InsertLineBusGrid()">Insert</button>
    }
    <div class="pull-right QuotaTabUpdateDivBtn">
        @if (Model.QuotaBusNewLineBtnView && !(Model.QuotaBusConfirmed))
        { 
            <button class="btn14" type="button" onclick="BusNewLine()">New Line</button>
        }
        @if (Model.QuotaBusUpdateBtnView && !(Model.QuotaBusConfirmed))
        {
            <button class="btn14" id="BusTabUpdate" type="button">Validate</button>
        }
    </div>
<div class="row form-row">
    <div class=" col-lg-2 withoutPadding" style="width: 17% !important; margin-left: 30px;">
        <div class="input-group">
            <span class="input-group-addon SumControlsLabelFSize" style="width: 30px !important;">@Html.LabelFor(model => model.DriverSum)</span>
            @Html.LabelForModel(Model.DriverSum, new { @class = "form-control SumControlsFSize" })
        </div>
    </div>
    <div class=" col-lg-2 withoutPadding" style="width: 13% !important; margin-left: 40px;">
        <div class="input-group">
            <span class="input-group-addon SumControlsLabelFSize" style="width: 30px !important;">@Html.LabelFor(model => model.TotalSum)</span>
            @Html.LabelForModel(Model.TotalSum, new { @class = "form-control SumControlsFSize" })
        </div>
    </div>
</div>
}





